﻿using System;
using SharpSqlAnalyzer.nodes;
using SharpSqlAnalyzer.pp.para.styleenums;
using SharpSqlAnalyzer.pp.processor.type.comm;
using SharpSqlAnalyzer.pp.utils;

namespace SharpSqlAnalyzer.pp.processor.type.createtable
{
	// Token: 0x02000248 RID: 584
	public class CreateTableItemAlignProcessor : AbstractProcessor
	{
		// Token: 0x06001307 RID: 4871 RVA: 0x0031C4D4 File Offset: 0x0031A6D4
		public override void process(TParseTreeNode nodeArg)
		{
			TColumnDefinitionList tcolumnDefinitionList = nodeArg as TColumnDefinitionList;
			TAlignOption parameter = this.getParameter<TAlignOption>(typeof(TAlignOption));
			if (tcolumnDefinitionList == null || tcolumnDefinitionList.size() == 0)
			{
				return;
			}
			if (this.Option.defaultAligntype != TAlignStyle.AsStacked)
			{
				return;
			}
			int num = 0;
			if (this.Option.defaultCommaOption == TLinefeedsCommaOption.LfbeforeCommaWithSpace)
			{
				num = 2;
			}
			int num2 = 0;
			for (int i = 0; i < tcolumnDefinitionList.size(); i++)
			{
				int num3 = tcolumnDefinitionList.getColumn(i).ColumnName.startToken.astext.Length + ((i != 0) ? num : 0);
				if (num3 > num2)
				{
					num2 = num3;
				}
			}
			for (int j = 0; j < tcolumnDefinitionList.size(); j++)
			{
				TSourceToken startToken = tcolumnDefinitionList.getColumn(j).ColumnName.startToken;
				int num4 = startToken.astext.Length + ((j != 0) ? num : 0);
				int num5 = num2 - num4;
				if (num5 > 0)
				{
					string text = Utils.createEmpty(num5);
					if (parameter == TAlignOption.AloLeft)
					{
						startToken.astext += text;
					}
					else if (parameter == TAlignOption.AloRight)
					{
						startToken.astext = text + startToken.astext;
					}
				}
			}
		}
	}
}
